﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkCommsDotNet.Tools;

namespace NetworkCommsDotNet
{
    /// <summary>
    /// 扩展
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// 提高
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="handler"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void Raise<T>(this EventHandler<T> handler, object sender, T args) where T : EventArgs
        {
            if (handler != null)
                handler(sender, args);
        }

    }

    /// <summary>
    /// 字符串事件参数
    /// </summary>
    public class StringEventArgs : EventArgs
    {
        /// <summary>
        /// 字符串事件参数
        /// </summary>
        /// <param name="text">字符串参数</param>
        public StringEventArgs(string text)
        {
            Text = text;
        }

        /// <summary>
        /// 字符串参数
        /// </summary>
        public string Text { get; set; }

    }

}

namespace System.Runtime.CompilerServices
{
    /// <summary>
    /// 
    /// </summary>
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
    public sealed class ExtensionAttribute : Attribute { }
}